

%% Mean based
realdata=y_hist(:,n_decomp);
histirf_cent=mean(histirf(:,:,:,:),4);
histempt_cent=mean(histempt(:,:,:,:),4);




%% Mean based - price - excluding deterministic

colorcode2=[0 0.7 0; 0 0 1; 0 1 1; 1 0 0; 0.5 0.5 0.5];
colorcode2=colorcode2([1:no_str  end], :);
figure('Name',['Figure ' figno ': Decomposition of Real House Prices'],'Units','centimeters','Position',[5 5 18 14])
set(gcf, 'Name',['Figure ' figno ': Decomposition of Real House Prices'],'NumberTitle','off') 
[hP, hB]=barExtended(gca,[squeeze(histirf_cent(n_decomp,end+1-gapstart:end,1:no_str)),sum(squeeze((histirf_cent(n_decomp,end+1-gapstart:end,no_str+1:n_var))),2)],'FaceColor','flat'); hold on, ...
 barExtenColor(colorcode2, hP, hB);
h1=plot(1:size(timestr,1),  realdata(end+1-gapstart:end,1)-squeeze(histempt_cent(n_decomp,end+1-gapstart:end,2))' ,'LineStyle', '-', 'LineWidth',1.5, 'Color','r'); hold on, ...
x = size(timestr,1)-5;
legend([hP h1],[shockname2, {'Residual','House Price'}],'Location','NorthWest')      
legend('boxoff')  
set(gca, 'XTick', spacing, 'XTickLabel', timestr(spacing));    
xlim([1 gapstart])
%ylim([-10 30])
box on
if savepic==1; grtitle=['hist'];  command=[ 'saveas(gcf, ''' outputfolder grtitle  ''' ,''png'')']; eval(command); end
